package ac2.util.sensors.sht11;

import ac2.util.TemperatureReadingConverter;

public class SHT11TemperatureReadingConverter
	extends TemperatureReadingConverter
{
	@Override
	public double ConvertReadingToCelcius(int reading) {
		return d1_celcius + (d2_celcius * reading);
	}

	@Override
	public double ConvertReadingToFahrenheit(int reading) {
		return d1_fahrenheit + (d2_fahrenheit * reading);
	}
	
	@Override
	public int ConvertCelciusToRaw(double temperature) {
		return (int) Math.round((temperature - d1_celcius) / d2_celcius);
	}

	@Override
	public int ConvertFahrenheitToRaw(double temperature) {
		return (int) Math.round((temperature - d1_fahrenheit) / d2_fahrenheit);
	}
	
	// These values are for the 3V VDD
	private double d1_celcius = -39.6;
	private double d1_fahrenheit = -39.3;
	
	// These values are for the 14 bit ADC
	private double d2_celcius = 0.01;
	private double d2_fahrenheit = 0.018;
	
}
